package cc.magicjson.example.demo.event;

import org.springframework.context.ApplicationEvent;

import java.io.Serial;
import java.util.EventObject;

/**
 * {@link ApplicationEvent}
 * 构建自定义的事件对象:用于创建事件 参考Spring ApplicationEvent
 *
 * @author <a href="mailto:it_magicjson@163.com">MagicJson</a>
 * @since 1.0.0
 */
public class CustomSpringApplicationEvent extends EventObject {

    private final long timestamp;

    @Serial
    private static final long serialVersionUID = 5639492747268476660L;

    /**
     * Constructs a prototypical Event.
     *
     * @param source the object on which the Event initially occurred
     * @throws IllegalArgumentException if source is null
     */
    public CustomSpringApplicationEvent(Object source) {
        super(source);
        this.timestamp = System.currentTimeMillis();
    }

    public final long getTimestamp() {
        return timestamp;
    }
}
